package cn.stylefeng.guns.modular.cb.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.cb.entity.CbEmail;
import cn.stylefeng.guns.modular.cb.model.params.CbEmailParam;
import cn.stylefeng.guns.modular.cb.model.result.CbEmailResult;
import cn.stylefeng.guns.modular.cb.service.CbEmailService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.kernel.model.response.ResponseData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 控制器
 *
 * @author wj
 * @Date 2021-01-09 12:29:32
 */
@RestController
@RequestMapping("/api/email")
public class CbEmailController extends BaseController {

    private static Logger logger = LoggerFactory.getLogger(CbEmailController.class);

    @Autowired
    private CbEmailService cbEmailService;

    /**
     * 新增接口
     *
     * @author wj
     * @Date 2021-01-09
     */
    @RequestMapping("/addItem")
    public ResponseData addItem(CbEmailParam cbEmailParam) {
        this.cbEmailService.add(cbEmailParam);
        return ResponseData.success(cbEmailParam.getId());
    }

    /**
     * 编辑接口
     *
     * @author wj
     * @Date 2021-01-09
     */
    @RequestMapping("/editItem")
    public ResponseData editItem(CbEmailParam cbEmailParam) {
        this.cbEmailService.update(cbEmailParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author wj
     * @Date 2021-01-09
     */
    @RequestMapping("/delete")
    public ResponseData delete(CbEmailParam cbEmailParam) {
        this.cbEmailService.delete(cbEmailParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author wj
     * @Date 2021-01-09
     */
    @RequestMapping("/detail")
    public ResponseData detail(CbEmailParam cbEmailParam) {
        CbEmail detail = this.cbEmailService.getById(cbEmailParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author wj
     * @Date 2021-01-09
     */
    @RequestMapping("/list")
    public LayuiPageInfo list(CbEmailParam cbEmailParam) {
        return this.cbEmailService.findPageBySpec(cbEmailParam);
    }

    /**
     * 获取邮箱
     *
     * @author wj
     * @Date 2021-01-09
     */
    @RequestMapping("/get_email")
    public ResponseData getEmail(CbEmailParam cbEmailParam) {
        CbEmailResult detail = this.cbEmailService.getEmail(cbEmailParam);
        return ResponseData.success(detail);
    }

    /**
     * 修改邮箱
     *
     * @author wj
     * @Date 2021-01-09
     */
    @RequestMapping("/edit_email")
    public ResponseData editEmail(CbEmailParam cbEmailParam) {
        this.cbEmailService.editEmail(cbEmailParam);
        return ResponseData.success();
    }
}


